package api

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto"
	"api-gateway/handler/request"
	"api-gateway/handler/resp"
	"github.com/gin-gonic/gin"
)

func AddReservation(c *gin.Context) {
	var req request.AddReservationReq
	if err := c.ShouldBind(&req); err != nil {
		resp.Error(c, 400, "参数有误", err.Error())
		return
	}

	reservation, err := config.DoctorClient.AddReservation(c, &__.AddReservationReq{
		PatientId:       req.PatientId,
		DoctorId:        req.DoctorId,
		ReservationTime: req.ReservationTime,
		Price:           req.Price,
	})

	if err != nil {
		resp.Error(c, 500, "服务端错误", err.Error())
		return
	}

	resp.Success(c, "预约添加成功", reservation.Url)

}

func GetOrderDetail(c *gin.Context) {
	var req request.GetOrderDetailReq
	if err := c.ShouldBind(&req); err != nil {
		resp.Error(c, 400, "参数有误", err.Error())
		return
	}

	orderDetail, err := config.DoctorClient.GetOrderDetail(c, &__.GetOrderDetailReq{
		OrderId: req.OrderId,
	})

	if err != nil {
		resp.Error(c, 500, "服务端错误", err.Error())
		return
	}

	resp.Success(c, "详情展示成功", orderDetail)
}
